﻿using Abide_Halo_Library;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Abide
{
    public static class MapHelper
    {
        public static MapVersion GetVersion(string FileLocation)
        {
            using (BinaryReader Reader = new BinaryReader(new FileStream(FileLocation, FileMode.Open), Encoding.ASCII))
            {
                Reader.BaseStream.Position = 4L;

                if (Reader.ReadInt32() == 8) //H2 or H2B map
                {
                    Reader.BaseStream.Position = 444L;
                    char[] Scenario = Reader.ReadChars(128);
                    if (new String(Scenario).Replace("\0", string.Empty) == string.Empty)
                        return MapVersion.Halo_2b;

                    return MapVersion.Halo_2;
                }

                throw new NotImplementedException("Map type not yet supported.");
            }
        }
    }
}
